﻿<template>
    <el-select v-model="nvalue" v-bind="$attrs" v-on="$listeners" filterable clearable placeholder="请选择" style="width: 100%">
        <el-option v-for="item in options"
                   :key="item.id"
                   :label="item.dict_label"
                   :value="item.dict_value">
        </el-option>
    </el-select>
</template>

<script>
    export default {
        data() {
            return {
                options: [],
                count: 0,
                loading: false,
                postData: { dict_type: null },
                nvalue: null
            }
        },
        model: {
            prop: 'value',
            event: 'change'
        },
        props: {
            value: {
                type: String,
                default: function () {
                    return null;
                }
            },
            dict_type: {
                type: String
            },
        },
        watch: {
            value: {
                async handler(newval, oldval) {
                    this.nvalue = newval;
                },
                immediate: true
            }
        },
        mounted: function () {
            this.load();
        },
        methods: {
            load: function () {
                this.postData.dict_type = this.dict_type;
                elm.post('/system/login/io/SelectDictList', this.postData)
                    .then((response) => {
                        this.options = response;
                    });
            }
        }
    }
</script>

<style scoped>
</style>